package models;

import views.TrueFalseQView;
import controllers.TrueFalseQController;
import mvc.AbstractView;
import answers.IAnswer;
import answers.Response;

public class TrueFalseQuestion extends AbstractQuestion
{
	public TrueFalseQuestion(String name, String caption)
	{
		super(name, caption);
	}
	
	public TrueFalseQuestion(String name, String caption, double points)
	{
		super(name, caption, points);
	}

	public void respond(Response response)
	{
		response.setQuestionPosition(position);
		IAnswer responseAnswer = response.getItsIAnswer();
		if(responseAnswer != null && itsIAnswer.compare(responseAnswer))
		{
			response.setScore(points);
		}
	}

	@Override
	public AbstractView createView()
	{
		if(itsIObservers.size() > 0)
		{
			return null;
			
		}
		
		TrueFalseQController controller = new TrueFalseQController(this);
		AbstractView view  = new TrueFalseQView(controller, this);
		this.attach(view);
		return view;
	}

	@Override
	public String getCategory()
	{
		return new String("True-false question");
	}
}
